<template>
  <div class="my">
    <div class="top">
      <div class="user">
        <div class="left">
          <div class="left-top">{{ userInfo.nickname }}</div>
          <div class="left-bottom">{{ userInfo.intro }}</div>
        </div>
        <!-- 点击头像跳转到myinfo页面 -->
        <img
          v-if="userInfo.avatar"
          class="right"
          :src="baseUrl + userInfo.avatar"
          alt=""
          @click="$router.push('/home/myInfo')"
        />
        <img
          v-else
          class="right"
          src="@/assets/logo.png"
          @click="$router.push('/home/myInfo')"
          alt=""
        />
      </div>
      <ul class="data">
        <li class="item">
          <div class="num">298</div>
          <div class="txt">累计答题</div>
        </li>
        <li class="item">
          <div class="num">98</div>
          <div class="txt">收藏题目</div>
        </li>
        <li class="item">
          <div class="num">198</div>
          <div class="txt">我的错题</div>
        </li>
        <li class="item">
          <div class="num">76%</div>
          <div class="txt">正确率</div>
        </li>
      </ul>
      <div class="data_cell">
        <mycell
          class="cell"
          icon="&#xe64d;"
          title="我的岗位"
          :value="userInfo.position"
          @click.native="$router.push('/home/editInfo?type=position')"
        >
        </mycell>
      </div>
    </div>

    <!-- 中间部份 -->
    <div class="content">
      <div class="middle">
        <h3>面经数据</h3>
        <ul class="data-total">
          <li class="total-item">
            <div class="t1">昨日阅读<span class="color">+300</span></div>
            <div class="num">17</div>
            <div class="txt">阅读总数据</div>
          </li>
          <li class="total-item">
            <div class="t1">昨日阅读<span class="color">+300</span></div>
            <div class="num">17</div>
            <div class="txt">获赞总数据</div>
          </li>
          <li class="total-item">
            <div class="t1">昨日阅读<span class="color">+300</span></div>
            <div class="num">17</div>
            <div class="txt">评论总数据</div>
          </li>
        </ul>
      </div>
      <div class="bottom">
        <mycell class="round" icon="&#xe655;" title="我的面经分享" value="21">
        </mycell>
        <mycell icon="&#xe655;" title="我的面经分享" value="21"></mycell>
        <mycell icon="&#xe655;" title="我的面经分享" value="21"></mycell>
        <mycell icon="&#xe655;" title="我的面经分享" value="21"></mycell>
        <mycell icon="&#xe655;" title="我的面经分享" value="21"></mycell>
        <mycell icon="&#xe655;" title="我的面经分享" value="21"></mycell>
      </div>
    </div>
  </div>
</template>

<script>
/* 组件套用组件 ,1.导入,主册,当标签使用 */
import mycell from './mycell'
/* 导入计算属性 */
import { mapState } from 'vuex'

export default {
  computed: {
    /* 在计算属性中定义 */
    ...mapState(['userInfo'])
  },
  components: {
    mycell
  },
  data () {
    return {
      baseUrl: process.env.VUE_APP_URL
    }
  }
}
</script>

<style lang="less" scoped>
.my {
  .top {
    position: relative;
    background-color: #c2002e;
    padding: 31px @p15 0;
    .data_cell {
      position: absolute;
      left: 0;
      bottom: -16px;
      padding: 0 @p15;
      width: 100%;
    }
  }
  .user {
    display: flex;
    align-items: center;
    .left {
      flex: 1;
      .left-top {
        font-size: 21px;
        font-family: PingFangSC, PingFangSC-Semibold;
        font-weight: 600;
        text-align: left;
        color: #ffffff;
        line-height: 30px;
        letter-spacing: 0px;
      }
      .left-bottom {
        opacity: 0.7;
        font-size: 12px;
        font-family: PingFangSC, PingFangSC-Regular;
        font-weight: 400;
        text-align: left;
        color: #ffffff;
        line-height: 16px;
        letter-spacing: 0px;
      }
    }
    .right {
      width: 50px;
      height: 50px;
      border: 3px solid rgba(255, 255, 255, 0.38);
      border-radius: 50%;
    }
  }
  .data {
    display: flex;
    // justify-content: space-between;
    justify-content: space-around;
    margin-top: 28px;
    padding-bottom: 55px;
    .num {
      font-size: 21px;
      font-family: DINAlternate, DINAlternate-Bold;
      font-weight: 700;
      text-align: center;
      color: #ffffff;
      line-height: 24px;
      letter-spacing: 0px;
    }
    .txt {
      opacity: 0.7;
      font-size: 12px;
      font-family: PingFangSC, PingFangSC-Regular;
      font-weight: 400;
      text-align: center;
      color: #ffffff;
      line-height: 16px;
      letter-spacing: 0px;
    }
  }
  .cell {
    border-top-left-radius: 10px;
    border-top-right-radius: 10px;
  }

  /* 面经数据 */
  .content {
    background-color: #f7f4f5;
    padding: 26px @p15;
    .middle {
      padding: 15px;
      background-color: #fff;
      border-radius: 8px;
      h3 {
        font-size: 14px;
        font-family: PingFangSC, PingFangSC-Semibold;
        font-weight: 600;
        text-align: center;
        color: #181a39;
        line-height: 20px;
        letter-spacing: 0px;
        margin-bottom: 20px;
      }
      .data-total {
        display: flex;
        justify-content: space-around;
        text-align: center;
      }
      .t1 {
        font-size: 10px;
        font-family: PingFangSC, PingFangSC-Regular;
        font-weight: 400;
        text-align: center;
        color: #b4b4bd;
        line-height: 14px;
        letter-spacing: 0px;
        .color {
          color: #38c7dd;
        }
      }
      .num {
        font-size: 21px;
        font-family: DINAlternate, DINAlternate-Bold;
        font-weight: 700;
        text-align: center;
        color: #181a39;
        line-height: 24px;
        letter-spacing: 0px;
      }
      .txt {
        font-size: 12px;
        font-family: PingFangSC, PingFangSC-Regular;
        font-weight: 400;
        text-align: center;
        color: #545671;
        line-height: 16px;
        letter-spacing: 0px;
      }
    }
  }
  .bottom {
    margin-top: 20px;
    .round {
      border-top-left-radius: 8px;
      border-top-right-radius: 8px;
    }
  }
}
</style>
